home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_10_01 / cips1001.exe / MAINEDGE.C < prev    next >
Text File  |  1991-04-20  |  4KB  |  124 lines

  1.  
  2.  
  3.        /***********************************************
  4.        *
  5.        *       file d:\cips\mainedge.c
  6.        *
  7.        *       Functions: This file contains
  8.        *          main
  9.        *
  10.        *       Purpose:
  11.        *          This file contains the main calling
  12.        *          routine in an edge detection program.
  13.        *
  14.        *       External Calls:
  15.        *          gin.c - get_image_name
  16.        *          numcvrt.c - get_integer
  17.        *                      int_convert
  18.        *          tiff.c - read_tiff_header
  19.        *          edge.c - quick_edge
  20.        *                   detect_edges
  21.        *          edge2.c - homogeneity
  22.        *                    difference_edge
  23.        *                    contrast_edge
  24.        *          edge3.c - gaussian_edge
  25.        *                    enhance_edges
  26.        *
  27.        *       
  28.        *       Modifications:
  29.        *          2 February 1991 - created
  30.        *
  31.        *************************************************/
  32.  
  33. #include "d:\cips\cips.h"
  34.  
  35.  
  36.  
  37. short the_image[ROWS][COLS];
  38. short out_image[ROWS][COLS];
  39.  
  40. main(argc, argv)
  41.    int argc;
  42.    char *argv[];
  43. {
  44.  
  45.    char name[80], name2[80];
  46.  
  47.    int  count, i, ie, il, j, le, length, ll, size, 
  48.         t, type, v, width;
  49.  
  50.  
  51.    struct   tiff_header_struct image_header;
  52.  
  53.    _setvideomode(_TEXTC80); /* MSC 6.0 statements */
  54.    _setbkcolor(1);
  55.    _settextcolor(7);
  56.    _clearscreen(_GCLEARSCREEN);
  57.  
  58.    if(argc < 7){
  59.     printf("\n\nNot enough parameters:");
  60.     printf("\n");
  61.     printf("\n   usage: mainedge   in-file   out-file   type ");
  62.     printf("  threshold?   threshold-value   size");
  63.     printf("\n   recall type: 1-Prewitt     2-Kirsch        3-Sobel");
  64.     printf("\n                4-quick       5-homogeneity   6-difference");
  65.     printf("\n                7-contrast    8-gaussian      9-enhance");
  66.     printf("\n   threshold?   1-threshold on   2-threshold off\n");
  67.     exit(0);
  68.    }
  69.  
  70.    strcpy(name, argv[1]);
  71.    strcpy(name2, argv[2]);
  72.    int_convert(argv[3], &type);
  73.    int_convert(argv[4], &t);
  74.    int_convert(argv[5], &v);
  75.    int_convert(argv[6], &size);
  76.  
  77.    il = 1;
  78.    ie = 1;
  79.    ll = ROWS+1;
  80.    le = COLS+1;
  81.  
  82.    read_tiff_header(name, &image_header);
  83.  
  84.    length = (90 + image_header.image_length)/ROWS;
  85.    width  = (90 +image_header.image_width)/COLS;
  86.    count  = 1;
  87.    printf("\nlength=%d  width=%d", length, width);
  88.  
  89.    for(i=0; i<length; i++){
  90.       for(j=0; j<width; j++){
  91.         printf("\nrunning %d of %d", count, length*width);
  92.         count++;
  93.         if(type == 9)
  94.            enhance_edges(name, name2, the_image, out_image,
  95.                       il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  96.                       le+j*COLS, v);
  97.         if(type == 8)
  98.            gaussian_edge(name, name2, the_image, out_image,
  99.                          il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  100.                          le+j*COLS, size, t, v);
  101.         if(type == 7)
  102.            contrast_edge(name, name2, the_image, out_image,
  103.                       il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  104.                       le+j*COLS, t, v);
  105.         if(type == 6)
  106.            difference_edge(name, name2, the_image, out_image,
  107.                       il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  108.                       le+j*COLS, t, v);
  109.         if(type == 5)
  110.            homogeneity(name, name2, the_image, out_image,
  111.                       il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  112.                       le+j*COLS, t, v);
  113.         if(type == 4)
  114.            quick_edge(name, name2, the_image, out_image,
  115.                       il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  116.                       le+j*COLS, t, v);
  117.         if(type == 3  ||  type == 2  ||  type == 1)
  118.            detect_edges(name, name2, the_image, out_image,
  119.                         il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  120.                         le+j*COLS, type, t, v);
  121.       }
  122.    }
  123.  
  124. }  /* ends main  */